#2008 Julka Lipkova
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade

import config
from creatortask import CreatorTask

#
# class for base editor window
#
class Editor:
    def __init__(self):
        self.glade = gtk.glade.XML( config.gladeFile( 'editorWindow.glade' ) )
        self.window = self.glade.get_widget( 'editorWindow' )
        self.glade.get_widget( 'notebookMain' ).set_current_page(0)

        self.creatorTask = CreatorTask()
        self.glade.get_widget( 'vboxPageCreator' ).pack_start( self.creatorTask.getMainWidget() )
        # TODO make this correctly in Creator
        self.creatorTask.connect('statusbar_notify', self.onStatusbarNotify )
        
        self.window.connect("destroy", self.destroy)
        self.glade.get_widget( 'btnQuit').connect( 'clicked', gtk.main_quit )

        self.window.show_all()
    
    def run(self):
        try:
            gtk.main()
        except KeyboardInterrupt:
            pass

    def onStatusbarNotify( self, sender, str ):
        sb = self.glade.get_widget( 'statusbar' )
        c = sb.get_context_id( 'notifications' )
        sb.pop( c )
        sb.push( c, str )

    def destroy(self, widget, data=None):
        gtk.main_quit()


# vim: set et ts=4 sw=4 sts=4 :
